#!/bin/bash
# up to date https://decloudflare.crimeflare.eu.org

#debugging/tracing which instances neeed a second look after daily run
#echo "$1:" $1
echo $1 >> /tmp/debug_cf_output1

#SEARCHY="^"$1"$"
#echo $SEARCHY
#DISK=/mnt/disk4
#SPLIT1=$DISK/data/deCloudflare/cloudflare_users
#SPLIT2=$DISK/data/deCloudflare/cloudflare_inc
#echo $SPLIT
#output=`grep  -r -i $SEARCHY $SPLIT1  -r | head -n 1`
#echo $output
#we used to have a local cache of crimeflare's data.  Where is it now??

echo curl -X POST -F \'f=$1\'  https://karma.crimeflare.eu.org/api/is/cloudflare/
curl -X POST -F 'f='$1  https://karma.crimeflare.eu.org/api/is/cloudflare/ 2>/dev/null > /tmp/cf_result_file
OUTSTRING=`cat /tmp/cf_result_file`

echo "OUTSTRING" $OUTSTRING

if [[ -z $OUTSTRING ]]; then 
echo "something went wrong"
exit 2;
fi

if [[ $OUTSTRING == "[false,false]" ]]; then 
echo "something went wrong"
exit 3;
fi

if [[ $OUTSTRING == "[true,true]" ]]; then 
echo "yes"
exit 0;
fi

if [[ $OUTSTRING == "[true,false]" ]]; then 
echo "no"
exit 1;
fi


#if [[  -z $output ]] ;   then
#output=`grep  -r -i $SEARCHY $SPLIT2  -r | head -n 1`
#if [[ -z $output ]] ;   then
#echo "no";
#exit 1;
#fi
#fi

#echo $1 > /tmp/debug_cf_output1
#if [  -z $output ] ;   then
#fi
#else
#echo $#
#echo $output
#echo "yes";
#exit 0;
#fi
